<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%" max-height="600">
      <el-table-column prop="classAlias" label="班别" show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        prop="teacherName"
        label="主讲教师"
        width="100"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column prop="totalCourseHours" label="总课时" width="100">
      </el-table-column>
      <el-table-column
        prop="courseStartDate"
        label="开课日期"
        width="100"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column prop="isFinish" label="是否结课" width="100">
        <template slot-scope="scope">
          <span v-show="scope.row.isFinish == 1">是</span>
          <span v-show="scope.row.isFinish != 1">否</span>
        </template>
      </el-table-column>
      <el-table-column prop="isFinish" label="操作" width="100">
        <template slot-scope="{ row }">
          <el-button type="success" size="mini" plain @click="handleView(row)"
            >查看详情</el-button
          >
        </template>
      </el-table-column>
      <div slot="empty" class="emptyBg">
        <el-empty :image-size="200"></el-empty>
      </div>
    </el-table>
    <Pagination
      v-show="parseInt(pageObj.count) > 0"
      :total="parseInt(pageObj.count)"
      @change="getList"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
    />
    <Detail />
  </div>
</template>
<script>
import { eduTeachingQuery } from '@/api/admin/teach/eduTeaching.js'
import Bus from '@/utils/bus.js'
export default {
  components: {
    Detail: () => import('./Detail.vue'),
  },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 10,
        studentId: '7d9298c124624b8c8cf158292524ca89',
      },
      tableData: [],
      pageObj: {},
    }
  },
  mounted() {
    this.getList()
    Bus.$on('refreshClasGradeList', (v) => {
      if (v) {
        Object.assign(this.listQuery, v)
      }
      this.getList()
    })
  },
  beforeDestroy() {
    Bus.$off('refreshClasGradeList')
  },
  methods: {
    getList() {
      eduTeachingQuery(this.listQuery).then((res) => {
        this.tableData = res.data.data
        this.pageObj = res.data
      })
    },
    handleView(row) {
      this.$bus.$emit('showDialogClassroom', row)
    },
  },
}
</script>
<style scoped>
.thumb {
  width: auto;
  height: 30px;
  cursor: pointer;
}
</style>